package com.freexiaoyu.cloud.ui.base;

import android.content.Context;
import android.os.Bundle;
import androidx.appcompat.app.AppCompatDialog;

import java.util.HashMap;
import java.util.Map;


/**
 * Created by DIY on 2018-12-04. 16:05
 * author:free宇
 * email:freexiaoyu@foxmail.com
 * describe:
 */

public abstract class BaseDialog extends AppCompatDialog {
    /**
     * final BaseDialog baseDialog=new BaseDialog(mContext, R.style.MyDialogStyle);
     *baseDialog.show();
     * */

    protected Context mContext;
    protected Map<String, Object> requestParams;
    protected String requestJson = "";//请求JSON格式
    protected Boolean isRefresh = true;//是否刷新
    protected int PAGE_INDEX = 1;//当前页码只有在列表中用到

    public BaseDialog(Context context) {
        super(context);
    }

    public BaseDialog(Context context, int theme) {
        super(context, theme);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestParams = new HashMap<>();
        mContext = getContext();
        init();
        setContentView(provideContentViewId());//布局
        initView();
        initData();
        initListener();
    }

    protected abstract int provideContentViewId();//用于引入布局文件

    /***
     * 在初始化布局之前操作
     */
    protected abstract void init();

    /***
     * 布局初始化完成后控件初始化
     */
    protected abstract void initView();

    /***
     * 在初始化布局之前操作
     */
    protected abstract void initData();

    /***
     * 事件
     */
    protected abstract void initListener();

}
